/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ticketmanager;

import java.util.ArrayList;

/**
 *
 * @author Viktor
 */
public class TextProcessor {

 /**
      * Replaces all '**' sets to new line symbol
      * merge multiple '**' lines in one pair
      * '**' and '\n' is HARDCODED
      * @param source
      * Source string
      * @param replace_what
      * !! NOT USED !!
      * Replace what
      * @param replace_with
      * Replace with
      * @return
      * Result string with replaced char sets
      */
     public String ReplaceSequence(String source, String replace_what, String replace_with)
     {


        if (!(source == null))
        {
         source = source.replaceAll("[**]{1,100}" , replace_with);
         source = source.replaceAll("^[\n ]{1,100}" , "");

        return source;
        }
        else
        {
        return "";
        }

     }

     /**
      * Replaces all '**' sets to new line symbol
      * merge multiple '**' lines in one pair
      * '**' and '\n' is HARDCODED
      * @param source
      * Source string array list
      * @param replace_what
      * !! NOT USED !!
      * Replace what
      * @param replace_with
      * Replace with
      * @return
      * Result set of string with replaced char sets
      */
     public ArrayList<String> ReplaceAll(ArrayList<String> source, String replace_what, String replace_with){

     ArrayList<String> result = new ArrayList<String>();

     for (String current: source) {
    if (!(current == null))
        {
         current = current.replaceAll("[**]{1,100}" , replace_with);
         current = current.replaceAll("^[\n ]{1,100}" , "");


         result.add(current);
         }
        else
        {
        result.add("");
         }

     }
    return result;
    }
}
